<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 100px;
            height: 100px;
            background-color: red;
            margin-top: 10px;
        }
        .box1{
            position: fixed;
            top: 20px;
            left: 50px;
        }
        .pre{
            position: relative;
        }
        .child{
            width: 50px;
            height: 50px;
            background-color: blue;
            position: absolute;
            top: 25px;
            left: 50px;
        }
        .sti{
            background-color: pink;
            position: sticky;
            top: 0;
            left: 200px;
        }
    </style>
</head>
<body>
    <!--
       static:浏览器默认定位
       fixed:固定定位
       relative: 子绝父相
       absolute: 子绝父相
       sticky:粘性定位
    -->
    <div class="box1">固定定位</div>
    <div class="pre">
        <div class="child">子盒子</div>
    </div>
    <div class=""></div>
    <div class="sti">黏性定位</div>
    <div class=""></div>
    <div class=""></div>
    <div class=""></div>
    <div class=""></div>
    <div class=""></div>
    <div class=""></div>
    <div class=""></div>
    <div class=""></div>
    <div class=""></div>
</body>
</html>